<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
<input type="text" v-model="num">
<input type="text" v-model="num2">
<input type="button" value="加" @click="f(1)">
<input type="button" value="减" @click="f(2)">
<input type="button" value="乘" @click="f(3)">
<input type="button" value="除" @click="f(4)"><br>

  结果：<span>{{info}}</span>
</div>
<script src="../js/vue.js"></script>
<script>
  let v =new Vue({
    el:"div",
    data:{
      num:"",num2:"",info:""
    },
    methods:{
      f(x){
        switch (x) {
          case 1: //加
            v.info=parseInt(v.num)+parseInt(v.num2);
            break;
          case 2: //减
            v.info=parseInt(v.num)-parseInt(v.num2);
            break;
          case 3: //乘
            v.info=parseInt(v.num)*parseInt(v.num2);
            break;
          case 4: //除
            v.info=parseInt(v.num)/parseInt(v.num2);
            break;
        }
      }
    }

  })
</script>
</body>
</html>